Conversation
otherwise when you decrement an object on line 90, you're decrementing ALL instances of this object.
seanohue
left a comment
There was a problem hiding this comment.
This is a good catch but I think the proper solution may be to use the item metadata to store the uses rather than the behavior config. The behavior config could still be used to determine the initial number of uses. This will prevent the decrement from happening on every instance but I think it will also prevent it from happening on the instance being used.
|
So we'd want to set the initial number of charges in the behavior config? And then in the use behavior, we want to check for presence of charge data in metadata? And if present, use that, if not present, then check for charge data in behavior config, and copy that to metadata? Basically, the initial count is set in the config, but all of the 'live data' lives in metadata? |
|
I think that would be ideal @ratacat, one major reason why being that the PR currently doesn't seem to "save" the decremented usages anywhere. It just clones the object from the behavior. Each time an item is used, the usages will be the same (as opposed to before where the usages were decremented globally for all instances). |
otherwise when you decrement an object on line 90, you're decrementing ALL instances of this object.